﻿using GalaSoft.MvvmLight;
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using WPRD.Extensions;

namespace WPRD.Models
{
    /// <summary>
    /// 雷达台站模型
    /// </summary>
    public partial class RadarSite : IDataErrorInfo
    {
        class RadarSiteMetadata
        {
            /// <summary>
            /// 区站号
            /// </summary>
            [Required(ErrorMessage = "区站号不能为空", AllowEmptyStrings = false)]
            public string StationNumber { get; set; }

            /// <summary>
            /// 台站名
            /// </summary>
            [Required(ErrorMessage = "台站名不能为空", AllowEmptyStrings = false)]
            public string Station { get; set; }

            /// <summary>
            /// 雷达型号
            /// </summary>
            [Required(ErrorMessage = "雷达型号不能为空", AllowEmptyStrings = false)]
            public string RadarType { get; set; }

            /// <summary>
            /// 天线所在经度
            /// </summary>
            [Required(ErrorMessage = "天线所在经度不能为空", AllowEmptyStrings = false)]
            [RegularExpression(@"^(\-|\+)?\d+(\.\d+)?$", ErrorMessage = "天线所在经度格式不正确")]
            public Decimal Longitude { get; set; }

            /// <summary>
            /// 天线所在纬度
            /// </summary>
            [Required(ErrorMessage = "天线所在纬度不能为空", AllowEmptyStrings = false)]
            [RegularExpression(@"^(\-|\+)?\d+(\.\d+)?$", ErrorMessage = "天线所在纬度格式不正确")]
            public Decimal Latitude { get; set; }

            /// <summary>
            /// 海拔高度
            /// </summary>
            [Required(ErrorMessage = "海拔高度不能为空", AllowEmptyStrings = false)]
            [RegularExpression(@"^(\-|\+)?\d+(\.\d+)?$", ErrorMessage = "海拔高度格式不正确")]
            public Decimal Altitude { get; set; }
        }

        /// <summary>
        /// 获取指示对象何处出错的错误信息。
        /// </summary>
        public string Error
        {
            get { return null; }
        }

        /// <summary>
        /// 获取具有给定名称的属性的错误信息。
        /// </summary>
        /// <param name="columnName">要获取其错误信息的属性的名称。</param>
        /// <returns></returns>
        public string this[string columnName]
        {
            get
            {
                return this.ValidateProperty<RadarSiteMetadata>(columnName);
            }
        }
    }
}
